//
//  V2MenuSingleCell.m
//  BaseProject
//
//  Created by 王洋 on 2021/4/26.
//  Copyright © 2021 王洋. All rights reserved.
//

#import "V2MenuSingleCell.h"

@implementation V2MenuSingleCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self.mainImageView pp_clipCorners:UIRectCornerAllCorners radius:6];
    });
}

- (void)fillWithModel:(V2CommonMenuModel *)model status:(V2MenuSingleCellStatus)status {

    [self.mainImageView sd_setImageWithURL:[NSURL URLWithString:model.dishesImg]];
    self.mainTitleLab.text = model.dishesName;
    
    if (status == V2MenuSingleCellStatus_edit) {
        self.selBtn.hidden = NO;
        [self.selBtn setImage:[UIImage imageNamed:model.isSelect?@"common_sel":@"common_nor"] forState:UIControlStateNormal];

    } else {
        self.selBtn.hidden = YES;
        [self.selBtn setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    }    
}

- (IBAction)selAction:(id)sender {
    if (self.selectSingleCellBlock) {
        self.selectSingleCellBlock();
    }
}

@end
